#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 6
#define M 7

int main()
{
    srand(time(NULL));
    int a[N][M];
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            a[i][j] = rand()%2;
        }
    }
    
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }

    printf("请输入 要占的连续座位数:\n");
    int num;
    scanf("%d", &num);

    int count = 0;
    for(int i = 0; i < N; i++)//行
    {
        int zero_num = 0;
        for(int j = 0; j < M; j++)//列
        {
            if(a[i][j] == 0)
            {
                zero_num++;
                if(zero_num >= num)
                    count++;
            }
            else
            {
                zero_num = 0;
            }
        }
    }

    printf("count = %d\n", count);

}